package com.ellricky.baselib.ui.order

import android.widget.ImageView
import androidx.core.content.ContextCompat
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.adapter.SmartViewHolder
import com.ellricky.baselib.R
import com.ellricky.baselib.entity.StudentWorkInfo
import com.ellricky.baselib.util.Ext.load

class StudentWorkAdapter :
    BaseRecyclerAdapter<StudentWorkInfo>(R.layout.base_adapter_student_work) {
    override fun onBindViewHolder(holder: SmartViewHolder, data: StudentWorkInfo, p2: Int) {
        holder.text(R.id.tv_work_time, data.job_createtime)
            .text(R.id.tv_work_person, "姓名：${data.log_member_name}  老师：${data.user_name}")
        holder.itemView.findViewById<ImageView>(R.id.iv_student_work_level).apply {
            when (data.job_level) {
                0 -> {
                    //未评估
                    setImageResource(0)
                }
                1 -> {
                    //优秀
                    setImageResource(R.drawable.base_icon_work_good)
                }
                2 -> {
                    //正常
                    setImageResource(R.drawable.base_icon_work_normal)
                }
                3 -> {
                    //差
                    setImageResource(R.drawable.base_icon_work_inferior)
                }
            }
        }
        holder.itemView.findViewById<ImageView>(R.id.iv_student_work_cover).apply {
            if (data.job_image.isNotEmpty()) {
                load(
                    data.job_image,
                    roundRadius = 20,
                    placeholder = R.drawable.base_bg_image_placeholder
                )
            } else {
                setImageDrawable(
                    ContextCompat.getDrawable(
                        context,
                        R.drawable.base_bg_image_placeholder
                    )
                )
                holder.itemView.findViewById<ImageView>(R.id.iv_student_work_level)
                    .setImageResource(R.drawable.base_icon_work_not_upload)
            }
        }
    }
}